#!/usr/bin/R --vanilla --slave -f
#
# Trying out raw vectors.

argv = commandArgs()
fifo.name = argv[[6]]

cat(paste("Opening", fifo.name, '\n'))

# blocking=T is important!
f = fifo(fifo.name, 'rb', blocking=T)

# readChar always returns a character
#c = readChar(f, 10, useBytes=T)
r = raw(2)

# read 21 bytes
c = readBin(f, "raw", n=10)

cat('\n')

cat(sprintf("%s\n", class(c)))
cat(sprintf("c: %s\n", c))

# Now I can slice it into bytes.
cat('substring', c[0:4], '\n')

#cat(sprintf("%s\n", class(r)))
#cat(sprintf("r: %s\n", r))
